package br.com.medmark.model.hibernate.dao;

import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;

import br.com.medmark.model.hibernate.Horario;
import br.com.medmark.model.hibernate.Profissional;

public class ProfissionalDAO extends GenericoDAOImpl<Profissional>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8376002535227375516L;
	
	private static ProfissionalDAO profissionalDao = null;
	
	private ProfissionalDAO(){
		
	}
	
	public static ProfissionalDAO getInstance(){
		
		if (profissionalDao == null) {
			profissionalDao = new ProfissionalDAO();
		}
	
		return  profissionalDao;
		
	}
	
	public Profissional getProfissional(int codigo) {
		String sql = "FROM Profissional p Where p.codigo = :codigo";
		
		TypedQuery<Profissional> query = this.entityManager.createQuery(sql, Profissional.class);
		query.setParameter("codigo", codigo);
	
		try {
			return query.getSingleResult();
		} catch (NoResultException ex) {
			return null;
		}
	}
	

}
